package com.itheima.controller;

import com.itheima.pojo.User;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;

@RestController
public class RequestController {
    @RequestMapping("/method1")
 public String method1(Integer age, Integer gender,@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime localDateTime){
        System.out.println(age);
        System.out.println(gender);
        System.out.println(localDateTime);
        return "success";
 }
 @RequestMapping("/method2")
 public String method2(User user){
        System.out.println(user);
        return "success";
 }
@RequestMapping("/method3")
 public String method3(String[] subjects){
    System.out.println(Arrays.toString(subjects));
    return "success";
 }

    @RequestMapping("/method4")
    public String method4(@RequestParam List<String> subjects){
        System.out.println(subjects);;
        return "success";
    }
    @RequestMapping("/method5")
    public String method5(@RequestBody User user){
        System.out.println(user);
        return "success";
    }
    @RequestMapping("/method6/{id}/{name}")
    public String method6(@PathVariable Integer id, @PathVariable String name){
        System.out.println(id);
        System.out.println(name);
        return "success";
    }

}
